package com.goodving.guli.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by john on 2015/11/23.
 */
public class WeightProgressBar extends View {
    private Paint f10834a;
    private float f10835b;
    private int f10836c;
    private int f10837d;
    private int f10838e;
    private int f10839f;
    private float f10840g;
    private float f10841h;
    private float f10842i;

    public WeightProgressBar(Context context) {
        this(context, null);
    }

    public WeightProgressBar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public WeightProgressBar(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f10834a = null;
        this.f10835b = 0.0f;
        this.f10836c = 0;
        this.f10837d = 0;
        this.f10838e = 0;
        this.f10839f = 0;
        this.f10840g = 150.0f;
        this.f10841h = 0.0f;
        this.f10842i = 0.0f;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C4005t.WeightProgressBar);
        this.f10835b = obtainStyledAttributes.getDimension(0, BitmapDescriptorFactory.HUE_ORANGE);
        this.f10836c = obtainStyledAttributes.getColor(1, -1);
        this.f10838e = obtainStyledAttributes.getColor(3, 0xEF6E67CF);
        this.f10837d = obtainStyledAttributes.getColor(2, 0xFF3C444F);
        this.f10839f = obtainStyledAttributes.getColor(4, 0xFF7EA800);
        this.f10840g = (float) obtainStyledAttributes.getInteger(5, C4220a.ap);
        this.f10841h = obtainStyledAttributes.getFloat(6, 0.0f);
        this.f10842i = obtainStyledAttributes.getFloat(6, 0.0f);
        obtainStyledAttributes.recycle();
        this.f10834a = new Paint();
        this.f10834a.setColor(this.f10838e);
        this.f10834a.setStyle(Paint.Style.STROKE);
        this.f10834a.setStrokeWidth(this.f10835b);
        this.f10834a.setAntiAlias(true);
    }

    private void m15361a() {
        invalidate();
    }

    public void m15362a(float f) {
        this.f10841h = f;
        m15361a();
    }

    public void m15363a(int i) {
        this.f10839f = i;
        m15361a();
    }

    public void m15364b(float f) {
        this.f10842i = f;
        m15361a();
    }

    public void m15365b(int i) {
        this.f10838e = i;
        m15361a();
    }

    public void m15366c(float f) {
        this.f10840g = f;
        m15361a();
    }

    public void m15367c(int i) {
        this.f10836c = i;
        m15361a();
    }

    public void m15368d(float f) {
        this.f10835b = f;
        m15361a();
    }

    public void m15369d(int i) {
        this.f10837d = i;
        m15361a();
    }

    @SuppressLint({"DrawAllocation"})
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawColor(this.f10837d);
        int width = getWidth() / 2;
        int i = (int) (((float) width) - (this.f10835b / 2.0f));
        RectF rectF = new RectF((float) (width - i), (float) (width - i), (float) (width + i), (float) (width + i));
        this.f10834a.setColor(this.f10838e);
        this.f10834a.setStrokeWidth(this.f10835b);
        canvas.drawArc(rectF, 135.0f, BitmapDescriptorFactory.HUE_VIOLET, false, this.f10834a);
        float f = (this.f10841h * BitmapDescriptorFactory.HUE_VIOLET) / this.f10840g;
        this.f10834a.setColor(this.f10839f);
        this.f10834a.setStrokeWidth(this.f10835b);
        canvas.drawArc(rectF, 135.0f, f, false, this.f10834a);
        if (this.f10842i > 0.0f) {
            float f2 = (this.f10842i * BitmapDescriptorFactory.HUE_VIOLET) / this.f10840g;
            this.f10834a.setColor(this.f10836c);
            this.f10834a.setStrokeWidth(this.f10835b + 1.0f);
            canvas.drawArc(rectF, 135.0f + f2, 1.0f, false, this.f10834a);
        }
    }
}
